package com.qfedu.edu.seckill.orderservice.config;

import com.qfedu.edu.seckill.orderservice.interceptor.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

import javax.naming.LimitExceededException;

/**
 * @author xiaobobo
 * @title: WebMvcConfig
 * @projectName cd-java-2404-seckill-parent
 * @description: TODO
 * @date 2025/2/5  15:31
 */
@SpringBootConfiguration
public class MyWebMvcConfig extends WebMvcConfigurationSupport {

    @Autowired
    private GlobalInterceptor globalInterceptor;

    @Override
    protected void addInterceptors(InterceptorRegistry registry) {
        //添加拦截器
        registry.addInterceptor(globalInterceptor).addPathPatterns("/orderservice/order/createOrder");
    }

    /**
     * 映射静态资源的位置的
     *
     * @param registry
     */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/**").addResourceLocations(
                "classpath:/static/");
        registry.addResourceHandler("swagger-ui.html").addResourceLocations(
                "classpath:/META-INF/resources/");
        registry.addResourceHandler("/webjars/**").addResourceLocations(
                "classpath:/META-INF/resources/webjars/");
    }
}
